home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / cli / bb2cli.lha / BBgoesCLI / ShowBB.asm < prev   
Assembly Source File  |  1992-09-02  |  4KB  |  192 lines

  1.  
  2. **********************************************************
  3. *          ShowBB v1.0               22.12.1994          *
  4. **********************************************************
  5. * copyright (c) 1994 by Jens Tröger, all rights reserved *
  6. *               this is Public Domain                    *
  7. **********************************************************
  8. *        written using HiSoft`s DevPac 3.04              *
  9. * greets fly to Oliver Reiff, "PackMAN" Falk Zühlsdorff  *
  10. * "Janosh" Jan Stötzer, Jan van den Baard,...            *
  11. **********************************************************
  12. * (non)sense: this will read the Bootblock from a given  *
  13. * floppy-drive and then write to stdio                   *
  14. * works with KS1.2 and better                            *
  15. * USAGE: ShowBB <unit>                                   *
  16. **********************************************************
  17.  
  18.     opt    o+,p+ 
  19.  
  20.     move.l    a0,a5 
  21.  
  22. ; ----- alloc memory for bootblock and several structures 
  23.  
  24. alloc_mem    move.l    4.w,a6 
  25.     move.l    #1024+88,d0    ; Bootblock + Port/IO... 
  26.     move.l    #$10001,d1 
  27.     jsr    -198(a6)        ; _LVOAllocMem 
  28.     move.l    d0,a4        ; a4: PTR to mem
  29.      beq    exit 
  30.  
  31. ; -----  open dos.library
  32.  
  33. open_dos    lea    dosname(pc),a1 
  34.     moveq    #33,d0 
  35.     jsr    -552(a6)        ; _LVOOpenLibrary 
  36.     move.l    d0,d6        ; d6: DOSBase
  37.     beq    free_mem 
  38.  
  39. ; -----  get unit 
  40.  
  41. read_unit    cmp.b    #"d",(a5)+ 
  42.     bne    usage 
  43.     cmp.b    #"f",(a5)+ 
  44.     bne    usage 
  45.     moveq    #0,d0 
  46.     move.b    (a5)+,d0 
  47.     sub.b    #48,d0 
  48.     cmp.b    #4,d0 
  49.     bge    usage
  50.     cmp.b    #0,d0
  51.     blt    usage
  52.     move.l    d0,d2         ; d2: Unit 
  53.     cmp.b    #":",(a5)+ 
  54.     bne    usage
  55.     adda.l    #1,a5
  56.     move.l    a5,a0 
  57. .loop    cmp.b    #10,(a0)+
  58.     bne.s    .loop
  59.     move.b    #0,-(a0)
  60.  
  61. ; -----  add MessagePort to system
  62.  
  63. add_port    sub.l    a1,a1 
  64.     jsr    -294(a6)        ; _LVOFindTask 
  65.     move.l    d0,1024+16(a4) 
  66.     lea    1024(a4),a1
  67.     jsr    -354(a6)        ; _LVOAddPort 
  68.  
  69. ; -----  open trackdisk.device 
  70.  
  71. open_track    lea    trackname(pc),a0 
  72.     lea    1024+32(a4),a1    ; a1: DiskIO-Struc 
  73.     move.l    d2,d0 
  74.     moveq    #0,d1 
  75.     jsr    -444(a6)        ; _LVOOpenDevice 
  76.     tst.l    d0 
  77.     bne    err_nodev        ; FATAL !!!!!
  78.  
  79. ; -----  read bootblock 
  80.  
  81. read_bb    lea    1024+46(a4),a0    ; a0: RepPort 
  82.     lea           1024(a4),a1    ; a1: ReplyPort-Struc 
  83.     move.l    a1,(a0) 
  84.     lea    1024+32(a4),a1    ; a1: DiskIO-Struc 
  85.     move.w    #2,28(a1) 
  86.     move.l    #1024,36(a1) 
  87.     move.l    a4,40(a1) 
  88.     move.l    #0,44(a1) 
  89.     jsr    -456(a6)        ; _LVODoIO 
  90.     move.l    d0,d2
  91.     move    #9,28(a1) 
  92.     move.l    #0,36(a1) 
  93.     jsr    -456(a6)        ; _LVODoIO 
  94.     tst.l    d2
  95.     bne.s    err_nodoio
  96.  
  97. ; -----  close trackdisk.device 
  98.  
  99. close_dev    lea     1024+32(a4),a1    ; a1: DiskIO-Struc 
  100.     jsr    -450(a6)        ; _LVOCloseDevice 
  101.  
  102. ; -----  remove port 
  103.  
  104. rem_port    lea    1024(a4),a1    ; a1: ReplyPort 
  105.     jsr    -360(a6)        ; _LVORemPort 
  106.  
  107. ; -----  make good (overwrite all non-writeable bytes with a point)
  108.  
  109. make_good    move.l    a4,a3
  110.     move.l    #1023,d0
  111. .loop    cmp.b    #" ",(a3)+
  112.     ble.s    .make
  113.     dbra    d0,.loop
  114.     bra.s    write
  115. .make    move.b    #".",-1(a3)
  116.     dbra    d0,.loop
  117.  
  118. ; -----  write to stdio
  119.  
  120. write    move.w    #$0a0a,1024(a4)
  121.     move.l    a4,a2
  122.     move.l    #1026,d3
  123.     bsr.s    write_msg
  124.  
  125. ; -----  close dos.library
  126.  
  127. close_dos    move.l    4.w,a6 
  128.     move.l    d6,a1 
  129.     jsr    -414(a6)        ; _LVOCloseLibrary 
  130.  
  131. ; -----  free allocated memory 
  132.  
  133. free_mem    move.l    a4,a1 
  134.     move.l    #1024+88,d0 
  135.     jsr    -210(a6)        ; _LVOFreeMem 
  136.  
  137. ; -----  returncode: 0 
  138.  
  139. exit    moveq    #0,d0 
  140.     rts 
  141.  
  142. ; -----  several messages
  143.  
  144. usage    lea    usage_text(pc),a2 
  145.     move.l    #usage_text_end-usage_text,d3 
  146.     bsr.s    write_msg
  147.     bra    close_dos 
  148.  
  149. err_nodev    lea    err1_text(pc),a2 
  150.     moveq    #38,d3 
  151.     bsr.s    write_msg
  152.     move.l    4.w,a6
  153.     lea    1024(a4),a1    ; a1: ReplyPort 
  154.     jsr    -360(a6)        ; _LVORemPort 
  155.     bra.s    close_dos
  156.  
  157. err_nodoio    lea    err2_text(pc),a2 
  158.     moveq    #44,d3 
  159.     bsr.s    write_msg
  160.     move.l    4.w,a6
  161.     lea     1024+32(a4),a1    ; a1: DiskIO-Struc 
  162.     jsr    -450(a6)        ; _LVOCloseDevice 
  163.      lea    1024(a4),a1    ; a1: ReplyPort 
  164.     jsr    -360(a6)        ; _LVORemPort 
  165.     bra.s    close_dos
  166.  
  167. ; -----  write 2 stdio
  168.  
  169. write_msg    move.l    d6,a6
  170.     jsr    -60(a6)        ; _LVOOutput
  171.     move.l    d0,d1
  172.     move.l    a2,d2
  173.     jmp    -48(a6)        ; _LVOWrite
  174.  
  175. ; -----  names, texts
  176.  
  177. dosname    dc.b    "dos.library",0 
  178.     even 
  179. trackname    dc.b    "trackdisk.device",0 
  180.     even 
  181. err1_text    dc.b    "FATAL ERROR opening trackdisk.device.",10 
  182.     even 
  183. err2_text    dc.b    "Error reading Bootblock. No disk inserted ?",10 
  184.     even 
  185. usage_text    dc.b    10,$9b,"1mShowBB v1.0",$9b,"0m 1994 by Jens Tröger",10 
  186.     dc.b    "USAGE: ShowBB <unit>",10 
  187.     dc.b    "Where <unit> is one of your mounted floppies (df0:) "
  188.     dc.b    10,10
  189. usage_text_end 
  190.  
  191.     end 
  192.